define(function (require, exports, module) {
	var Component = require("grid");
	var Dialog=require("dialog");
	var aw = require("ajaxwrapper");
	var fetchProperties = require("../constant/fetchProperties");
	var gridEvents = require("../handler/gridEvents");
    var instance = {
        initComponent : function (params, widget) {
            var component = new Component({
            	parentNode : ".J-watergrid",
            	autoRender:false,
                model :  {
                columns  : [{
					 name : "room.code",
					 label : "房号",
					 format:function(value,row){
						 return row.room.orgBuilding.name+"-"+row.room.code;
					 }
				 },/*{
					 name : "checkInMeterDate",
					 label : "入住抄表日期",
					 format :"date",
					 formatparams:{
							mode:"YYYY-MM-DD"
					 }
				 },*/{
					 name : "electricMeter",
					 label : "入住电表值",
				 },{
					 name : "waterMeter",
					 label : "入住冷水表值",
				 },{
					 name : "hotWaterMeter",
					 label : "入住热水表值",
				 },/*{
					 name : "checkOutMeterDate",
					 label : "退住抄表日期",
					 format :"date",
					 formatparams:{
							mode:"YYYY-MM-DD"
					 }
				 },*/{
					 name : "checkOutElectricMeter",
					 label : "退住电表值",
				 },{
					 name : "checkOutWaterMeter",
					 label : "退住冷水表值",
				 },{
					 name : "checkOutHotWaterMeter",
					 label : "退住热水表值",
				 },/*{
					 name : "roomStatus.value",
					 label : "状态",
				 },*/{
					 name : "operate",
					 label : "操作",
					 format:"button",
						formatparams:[{
							id:"checkIn",
							text:"入住抄表",
							show:function(value,data){
								if(data.roomStatus.key == "NoCheckIn"){
									return true;
								}else{
									return false;
								}
							},
							handler:function(index,data,rowEle){
								if(data.roomStatus.key == "NoCheckIn"){
									gridEvents.UpDateMeter(data,widget);
								}else{
									Dialog.alert({
				                		title:"提示",
				                		content:"该状态下不能进行入住抄表！"
				                	});
									return false;
								}
							}
						},{
							id:"checkOut",
							text:"退住抄表",
							show:function(value,data){
								if(data.roomStatus.key == "CheckIn"){
									return true;
								}else{
									return false;
								}
							},
							handler:function(index,data,rowEle){
								if(data.roomStatus.key == "CheckIn" && widget.get("checkInStatusKey") == "CheckIn"){
									gridEvents.UpDateMeter(data,widget);
								}else{
									Dialog.alert({
				                		title:"提示",
				                		content:"该状态下不能进行退住抄表！"
				                	});
									return false;
								}
							
							}
						}]
				 }]
				}
            });
            widget.set("endGrid",component);
        }
    };
    module.exports = instance;
});